<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "ad".
 *
 * @property int $id
 * @property string $cover
 * @property string $target
 * @property int $status
 * @property int $created_at
 */
class Ad extends Base
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'ad';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['pid', 'type', 'status', 'created_at'], 'integer'],
            [['cover', 'target', 'video_url'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'cover' => 'Cover',
            'target' => 'Target',
            'status' => 'Status',
            'created_at' => 'Created At',
        ];
    }

    public function getPosition(){
        return $this->hasOne(AdPosition::class, ['id' => 'pid']);
    }
}
